open Jopruntime
open Jopruntime.Circuit

let half_add a b =
  < s,c >
    | s = xor_ a b
    | c = and_ a b
;;

let full_add a b ci =
  < s,co ; u,v,w >
    | u,v = half_add a b
    | s,w = half_add u ci
    | co = or_ w v
;;

let main () =
  < a,b,ci,s,co >
    | a = input "a" 1
    | b = input "b" 1
    | ci = input "ci" 1

    | s,co = full_add a b ci

    | (output "out" (flatten [co; s]))
;;

(* Ligne qu'on pourra retirer plus tard *)
temp_gen (fst (main ())) Sys.argv.(1);;
